Resetting root (admin) password using "chroot" on a LUKS encrypted+lvm filesystem

 

Sometimes useful if you're locked out of a machine where you've forgotten your user or root password.

Boot up live session ... in console mode will do for our purposes, which is a lot faster.

Become root with "sudo su", (Elive will not prompt for a password) and decrypt the filesystem on the machine you're locked out of (we'll call it "lost-machine" from now on) which, in my case is /dev/sda3.

"cryptsetup luksOpen /dev/sda3 lost-machine"

and enter the decryption password when prompted.

Mount the unencrypted filesystem on "lost-machine" (you'll want the / filesystem where passwords are stored):

"mount /dev/mapper/elive_vg-root_lv /mnt"

Check if it is indeed the wanted root filesystem with "ls /mnt"

and "mount" to see if it is indeed mounted "rw". Specifically "w" for write is a necessity to make changes.

chroot into /mnt :

"chroot /mnt " And you're running your lost-machine as root in single user mode (init 1)

 

If you don't know the user name on lost-machine do:

"less /etc/group" where you'll probably be wanting the adm: user ... or to show other users do

"less /etc/group |grep 100"

And reboot the machine with Ctrl,Altand Del combo. You'll find the passwords changed as wanted. :smiley14: